package com.xxx.common.model;

import com.xxx.common.constant.ParametersConstants;
import com.xxx.common.enums.LanguageType;
import com.xxx.servlet.HttpServletUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author leiming
 * @Description
 * @date 18:44 2018/8/30
 **/
@ApiModel("语言的请求参数")
@Data
@Slf4j
public class ReqLanguageInfo {

    @ApiModelProperty(value = "语言", hidden = true)
    private LanguageType lan;

    public LanguageType getLan(){
        return getLanguageType();
    }

    public static LanguageType getLanguageType(){
        try {
            Object languageObj = HttpServletUtil.getHttpServletRequest().getAttribute(ParametersConstants.LANGUAGE);
            if(languageObj!=null){
                return (LanguageType)languageObj;
            }else{
                return LanguageType.CN;
            }
        }catch (Exception e){
            return LanguageType.CN;
        }

    }


}
